import React, { Component } from 'react';
import { withRouter } from 'react-router-dom'
import NavBar from './components/Nav';
import Loading from './components/Loading';
import { Provider } from 'react-redux'
import store from './store'
import Alert from './components/Alert'


class App extends Component {
  render() {
    return (
      <>
        <Provider store={store}>
          <Alert></Alert>
          {/* 路由插槽 */}
          <>{this.props.children}</>
          <Loading />
        </Provider>
        <NavBar />
      </>
    );
  }
  UNSAFE_componentWillMount() {
    // 用不了路由的东西
    // console.log(this.props)
    if (this.props.location.pathname === '/') {
      this.props.history.push('/home')
    }

  }
}

export default withRouter(App);
// 函数是组件的路由重定向
// import React, { useEffect } from 'react'
// import { useHistory } from 'react-router-dom'
// function App(props) {
//   console.log(useHistory())
//   let history = useHistory();
//   useEffect(() => {
//     // console.log(props)
//     if (history.location.pathname === '/') {
//       history.push('/home')
//     }
//   }, [])
//   return (
//     <div>
//       更逐渐
//       <div>{props.children}</div>
//     </div>
//   )
// }
// export default App